package com.songminju.sqlsong;

import java.sql.SQLException;

import javax.sql.DataSource;

import com.songminju.sqlsong.exector.DataSourceSsqlExecutor;
import com.songminju.sqlsong.exector.SsqlExecutor;
import com.songminju.sqlsong.orm.JpaOrmManager;
import com.songminju.sqlsong.orm.OrmManager;

public class SqlSongFactory {
	private DataSource dataSource = null;
	private OrmManager ormManager = null;
	
	public SqlSongFactory(DataSource dataSource){
		this.dataSource = dataSource;
		ormManager = new JpaOrmManager();
	}
	
	public void registerEntity(@SuppressWarnings("rawtypes") Class c) {
		ormManager.registerEntity(c);
	}
	
	public SsqlExecutor ssqlExecutor() {
		try {
			return new DataSourceSsqlExecutor(dataSource.getConnection(),ormManager);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
	
}
